#一个简单的部署脚本
docker run -d --name broker apache/kafka:3.7.1

# https://juejin.cn/post/7380421216019365897
docker stop kafka && docker rm kafka
docker run -itd --name kafka \
-p 9092:9092 \
-p 9093:9093 \
-v /mnt/data/software/kafka/config:/mnt/shared/config \
-v /mnt/data/software/kafka/data:/var/lib/kafka/data \
-v /mnt/data/software/kafka/secret:/etc/kafka/secrets \
-e LANG=C.UTF-8 \
-e KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT \
-e CLUSTER_ID=the-custom-id \
-e KAFKA_NODE_ID=1 \
-e KAFKA_PROCESS_ROLES=broker,controller \
-e KAFKA_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://61.172.179.48:9092 \
-e KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER \
-e KAFKA_CONTROLLER_QUORUM_VOTERS="1@127.0.0.1:9093" \
apache/kafka:3.7.1

# 使用下面这个命令启动kafka单机版
docker stop kafka && docker rm kafka
docker run -itd --name kafka -p 9092:9092 -p 9093:9093 \
-v /mnt/data/software/kafka/data:/var/lib/kafka/data \
-e KAFKA_NODE_ID=1 \
-e KAFKA_PROCESS_ROLES=broker,controller \
-e KAFKA_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://61.172.179.48:9092 \
-e KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER \
-e KAFKA_CONTROLLER_QUORUM_VOTERS=1@61.172.179.48:9093 \
-e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT \
-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
-e KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 \
-e KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1 \
-e KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0 \
-e KAFKA_NUM_PARTITIONS=3 \
apache/kafka:3.7.1
docker logs -f kafka